//
//  RootTabBarController.m
//  GiftSay
//
//  Created by oneDay on 15/10/16.
//  Copyright (c) 2015年 oneDay All rights reserved.
//

#import "RootTabBarController.h"
#import "StyleViewController.h"
#import "VideoViewController.h"
#import "MineViewController.h"
#import "ArticleViewController.h"


@interface RootTabBarController ()

@end

@implementation RootTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.translucent = NO;
    [self addLayOut];
    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"isLogin"];
    
//    // 判断是否轻量级持久化账号
//    NSString *userName = [[DataManager shareManager] userName];
//    if ([userName isEqualToString:@""]) {
//        
//    }else{
//        // 设置登录状态为NO
//        [[DataManager shareManager] isLogin:YES];
//    }
    // 设置登录状态为NO
    [[DataManager shareManager] isLogin:NO];
    // 创建数据库表
    [[DataManager shareManager] creatTable];
}

#pragma mark -- layout
- (void)addLayOut
{
    [self addViewControllersClass:[StyleViewController class] title:@"主页" image:@"iconfont-zhuye-2" selectImage:@"iconfont-zhuye"];
    [self addViewControllersClass:[ArticleViewController class] title:@"美文" image:@"iconfont-iconfontshu-2" selectImage:@"iconfont-iconfontshu"];
    [self addViewControllersClass:[VideoViewController class] title:@"视频" image:@"iconfont-video-2" selectImage:@"iconfont-video"];
    [self addViewControllersClass:[MineViewController class] title:@"我的" image:@"iconfont-mynormal-2" selectImage:@"iconfont-mynormal"];
}

- (void)addViewControllersClass:(Class)class title:(NSString *)title image:(NSString *)image selectImage:(NSString *)selectImage
{
    UIViewController *viewC = [[class alloc] init];
    UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:viewC];
    navC.tabBarItem.title = title;
    navC.tabBarItem.image = [UIImage imageNamed:image];
    navC.tabBarItem.selectedImage = [UIImage imageNamed:selectImage];
    
    [self addChildViewController:navC];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
